using System.Runtime.CompilerServices;
using UnityEngine;

public class CameraViewTrigger : MonoBehaviour
{
	public delegate void CameraViewTriggerHandler(CameraHorizontalFollowMode viewType, GameObject trigger);

	public CameraHorizontalFollowMode cameraViewType;

	[method: MethodImpl(32)]
	public static event CameraViewTriggerHandler CameraViewTriggerEnterEvent;

	[method: MethodImpl(32)]
	public static event CameraViewTriggerHandler CameraViewTriggerExitEvent;

	public static void CameraViewTriggerEnter(CameraHorizontalFollowMode viewType, GameObject trigger)
	{
		if (CameraViewTrigger.CameraViewTriggerEnterEvent != null)
		{
			CameraViewTrigger.CameraViewTriggerEnterEvent(viewType, trigger);
		}
	}

	public static void CameraViewTriggerExit(CameraHorizontalFollowMode viewType, GameObject trigger)
	{
		if (CameraViewTrigger.CameraViewTriggerExitEvent != null)
		{
			CameraViewTrigger.CameraViewTriggerExitEvent(viewType, trigger);
		}
	}

	private void OnTriggerEnter()
	{
		CameraViewTriggerEnter(cameraViewType, base.gameObject);
	}

	private void OnTriggerExit()
	{
		CameraViewTriggerExit(cameraViewType, base.gameObject);
	}

	private void Awake()
	{
		LevelController.LevelReadyEvent += OnLevelReady;
	}

	private void OnDestroy()
	{
		LevelController.LevelReadyEvent -= OnLevelReady;
	}

	private void OnLevelReady(Transform levelTransform)
	{
		if (base.transform.root == levelTransform)
		{
			base.gameObject.isStatic = true;
		}
	}
}
